/*
 * @Author: huangkaicheng@rfchina.com
 * @Date: 2021-1-28 16:54:02
 * @LastEditTime: 2021-01-28 15:01:02
 * @LastEditors: huangkaicheng@rfchina.com
 * @Description: Compile LESS 2 Other
 * @FilePath: \rf-auto-jenkins-plugin\lib\lessCompile.js
 */
const fs = require("fs");
const path = require("path");
const inquirer = require("inquirer");
const LessCompile = require("../lessCompile/lessCompile");
const chalk = require("chalk");
module.exports = function lessCompile(program) {
  program
    .command("less")
    .option("-s,--suffix [suffix] ", `Compile nameSuffix`)
    .description(`Compile less 2 other by less`)
    .action(async (options) => {
      //如果有直接传后缀名参数的话，就直接执行
      if (options.suffix) {
        console.log(options.suffix);
        LessCompile(process.cwd(), options.suffix);
      } else {
        inquirer
          .prompt([
            {
              type: "input",
              name: "suffix",
              message: "请输入想转化的文件后缀名（css/wxss）,不填则默认为wxss",
            },
          ])
          .then(async (res) => {
            let suffix = res.suffix || "wxss";
            LessCompile(process.cwd(), suffix);
          });
      }
    });
};
